//
//  select_Collection_Cell.m
//  Food
//
//  Created by dllo on 15/7/27.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "select_Collection_Cell.h"
#import "UIImageView+WebCache.h"
@implementation select_Collection_Cell
-(void)dealloc
{
    [_imageView release];
    [_lable release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageView];
        
        self.lable = [[UILabel alloc] init];
        [self.lable setTextAlignment:NSTextAlignmentCenter];
        [self.contentView addSubview:self.lable];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.imageView.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height - 20);
    self.lable.frame = CGRectMake(0, self.imageView.frame.size.height, layoutAttributes.frame.size.width, 20);
}

- (void)setModel:(selectData *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.imagePath]];
    self.lable.text = model.name;
}
@end
